/*
 * ============================================================================
 *
 *       Filename:  ceshi.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2013年09月18日 10时37分38秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * ============================================================================
 */
#include <stdio.h>
#include <stdint.h>
#include <string.h>

static inline int _strcmp(char *str1, char *str2)
{
	int i = 0;
	while(1) {
		switch(str1[i]) {
		case '/': case '\0':
			if(str2[i] == '/' || str2[i] == '\0')
				return 1;
			else
				return 0;
			break;
		default:
			if(str1[i] != str2[i])
				return 0;
			break;
		}
		i++;
	}
}

static inline int 
strcmp_in(char *dstr, char *sstr)
{
	int i, pattern_len = strlen(sstr);
	char *p = sstr;
	char *tmp = p;


	for(i = 0; i <= pattern_len; i++) {
		if(*p == '/' || *p == 0) {
			if(_strcmp(dstr, tmp))
				return 1;
			tmp = p + 1;
		}
		p++;
	}
	return 0;
}


int main()
{
	char str[] = "HFA/ACL/";
	if(strcmp_in("HFA/", str))
		printf("in\n");
	if(strcmp_in("AC/", str))
		printf("in\n");
}
